<?php
session_start();
require_once("../includes/public.inc.php");
$type = isset($_GET['type'])?$_GET['type']:'';
$username = isset($_SESSION['username'])?$_SESSION['username']:'';
if (empty($username))
{
	echo "<script>alert('亲你还没有登录哦');history.back();</script>";	exit;
}
$name = isset($_POST['name'])?$_POST['name']:'';
$sex = isset($_POST['sex'])?$_POST['sex']:'';
$shopname = isset($_POST['shopname'])?$_POST['shopname']:'';
$shopaddress = isset($_POST['shopaddress'])?$_POST['shopaddress']:'';
$job = isset($_POST['job'])?$_POST['job']:'';
$address = isset($_POST['address'])?$_POST['address']:'';
if ($type=='dg')
{
	$user = mysql_fetch_array(mysql_query("select * from ".DBQIAN."daogou where username='".$username."' order by id desc limit 1"));
	if ($user)
	{
		$result = mysql_query("update ".DBQIAN."daogou set name='".$name."',sex=".$sex.",shopname='".$shopname."',shopaddress='".$shopaddress."',job=".$job." where username='".$username."'");
		if ($result)
		{
			echo"<script>alert('修改成功');history.go(-1);</script>";  
		}
		else 
		{
			echo"<script>alert('修改失败');history.go(-1);</script>";
		}
	}
	else 
	{
		echo"<script>alert('修改失败');history.go(-1);</script>";  	
	}
}
else 
{
	$user = mysql_fetch_array(mysql_query("select * from ".DBQIAN."users where username='".$username."' order by id desc limit 1"));
	if ($user)
	{
		$result = mysql_query("update ".DBQIAN."users set name='".$name."',sex=".$sex.",address='".$address."' where username='".$username."'");
		if ($result)
		{
			echo"<script>alert('修改成功');history.go(-1);</script>"; 
		}
		else 
		{
			echo"<script>alert('修改失败');history.go(-1);</script>";
		}
	}
	else 
	{
		echo"<script>alert('修改失败');history.go(-1);</script>";  	
	}
}